package funcs

import (
	"log"
	"probeping/src/store"
	"strconv"

	_ "github.com/glebarez/go-sqlite"
)

func ClearArchive() {
	log.Println("[func:ClearArchive] ", "starting run ClearArchive ")
	store.DLock.Lock()
	store.Db.Exec("delete from alertlog where logtime < date('now','start of day','-" + strconv.Itoa(store.Cfg.ArchiveDay) + " day')")
	store.Db.Exec("delete from mappinglog where logtime < date('now','start of day','-" + strconv.Itoa(store.Cfg.ArchiveDay) + " day')")
	store.Db.Exec("delete from pinglog where logtime < date('now','start of day','-" + strconv.Itoa(store.Cfg.ArchiveDay) + " day')")
	store.DLock.Unlock()
	log.Println("[func:ClearArchive] ", "ClearArchive Finish ")
}
